package com.szty.lib_pen.sendPoint.room

import androidx.room.*

@Dao
interface DotDao {
    @Query("SELECT* FROM dotbean")
    fun getAll(): List<DotBean>
    @Query("SELECT COUNT(*) FROM dotbean")
    fun getCount(): Int

    @Query("SELECT* FROM dotbean WHERE uid IN (:userIds)")
    fun loadAllByIds(userIds: IntArray): List<DotBean>

    /**
     * 查询最后一个数据，如果表是空的，会返回null
     */
    @Query("SELECT * FROM dotbean ORDER BY uid  DESC LIMIT 1")
    fun getLastData(): DotBean

    /**
     * 查询最后一个数据，如果表是空的，会返回null
     */
    @Query("SELECT * FROM dotbean LIMIT 1")
    fun getFirstData(): DotBean

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertAll(vararg dotBean: DotBean)

    @Delete
    fun delete(dot: DotBean)

    @Query("DELETE FROM dotbean")
    fun deleteAll()
}
